package com.dh.service.impl;

import com.dh.entity.Notice;
import com.dh.repository.NoticeRepository;
import com.dh.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

@Service
public class NoticeServiceImpl implements NoticeService {

    @Autowired
    private NoticeRepository noticeRepository;


    public Page<Notice> page(PageRequest pageRequest) {
        return noticeRepository.findAll(pageRequest);
    }

    public void create(Notice notice) {
        noticeRepository.save(notice);
    }

    public void update(Notice notice) {
        noticeRepository.save(notice);
    }

    public Notice get(Long noticeId) {
        return noticeRepository.findOne(noticeId);
    }


    public void delete(Long noticeId) {
        noticeRepository.delete(noticeId);
    }

    @Override
    public Notice findByNoAndDeleted(String no, byte deleted) {
        return noticeRepository.findByNoAndDeleted(no, deleted);
    }
}
